export const initForm = () => {
  return {
  }
}

export const rules = {
  deptName: [
    { required: true, message: "必填", trigger: "blur" },
  ],
  orderNum: [
    { required: true, message: "必填", trigger: "blur" },
  ],
}

// 回显数据字典
export function selectDictLabel(datas, value) {
  var actions = [];
  Object.keys(datas).some((key) => {
    if (datas[key].dictValue == ('' + value)) {
      actions.push(datas[key].dictLabel);
      return true;
    }
  })
  return actions.join('');
}

export const getParentName = (id, list) => {
  if (id === "-1") return "顶部部门"
  let parentName = ""
  let fn = (id, data) => {
    for (let item of data) {
      if (item.id === id) {
        parentName = item.deptName
        return false
      }
      if (item.children && item.children.length > 0) {
        fn(id, item.children)
      }
    }
  }
  fn(id, list)
  return parentName
}